@ECHO OFF

SETLOCAL EnableDelayedExpansion
:loop
SET adapterName=

FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "ETHERNET ADAPTER"') DO (
	SET adapterName=%%a

	REM Removes "Ethernet adapter" from the front of the adapter name
	SET adapterName=!adapterName:~17!

	REM Removes the colon from the end of the adapter name
	SET adapterName=!adapterName:~0,-1!

	netsh interface ipv4 set dns name="!adapterName!" static 127.0.0.1 primary	
)
ipconfig /flushdns

timeout 300
goto loop

:EOF